<template>
	<view class="page">
		
		<view style="display: flex;flex-direction: row;justify-content: space-between;background: #FFFFFF;">
		    <view style="margin-left: 176upx;display: flex;flex-direction: column;align-items: center;" @click="switchTab(1)">
				<view style="font-size: 32upx;color: #191919;font-weight: bold;">
					余额
				</view>
				<image v-if="isSelect" style="width: 48upx;height: 16upx;" 
				src="../../static/images/publish-scoll.png" mode=""></image>
			</view>
			<view style="margin-right: 176upx;display: flex;flex-direction: column;align-items: center;" @click="switchTab(2)">
				<view style="font-size: 32upx;color: #191919;font-weight: bold;">
					预计入账
				</view>
				<image v-if="!isSelect" style="width: 48upx;height: 16upx;"
				 src="../../static/images/publish-scoll.png" mode=""></image>
			</view>
		</view>
		
		
		<view v-if="isSelect">
			<view style="background: #FFFFFF;width: 702upx;height: 394upx;display: flex;flex-direction: column;align-items: center;
			margin-left: 24upx;margin-right: 24upx;margin-top: 24upx;border-radius: 24upx;">
				<view style="color: #191919;font-size: 30upx;margin-top: 50upx;">账户余额(元)</view>
				<view style="color: #191919;font-size: 72upx;font-weight: bold;margin-top: 20upx;">{{balanceRecordList.totalIncome}}.00</view>
				<view style="background: #FF4E4C;color: #FFFFFF;font-size: 28upx;
				height: 72upx;width: 268upx;line-height: 72upx;text-align: center;
				border-radius: 48upx;margin-top: 40upx;"  @click="applyWithdraw" v-if="balanceRecordList.totalIncome!==0">
					
					提现
				</view>
				
				<view style="background: #FFBCBB;color: #FFFFFF;font-size: 28upx;
				height: 72upx;width: 268upx;line-height: 72upx;text-align: center;
				border-radius: 48upx;margin-top: 40upx;"  v-if="balanceRecordList.totalIncome===0" >
					
					提现
				</view>
			</view>
			
			<view style="border-radius: 24upx;background: #FFFFFF;margin-top: 24upx;margin-left: 24upx;margin-right: 24upx;height: 100%;" >
				<view style="border-bottom: 2upx solid #F4F4F4;width: 654upx;height: 96upx;line-height: 96upx;margin-left: 24upx;" >余额明细</view>
				<view v-for="(item,index) in balanceRecordList.detailList" :key="index">
					<view style="display: flex;flex-direction: row;justify-content: space-between;margin-top: 24upx;
					margin-left: 24upx;margin-right: 24upx;">
						<view style="color: #191919;font-size: 28upx;">{{item.accountTypeName}}</view>
						<view style="color: #191919;font-size: 32upx;">{{item.amount}}</view>
					</view>
					<view style="display: flex;flex-direction: row;justify-content: space-between;margin-top: 8upx;margin-left: 24upx;margin-right: 24upx;">
						<view style="color: #A6A6A6;font-size: 26upx;">
							{{item.createTime}}
						</view>
						<view style="color: #A6A6A6;font-size: 26upx;" v-if="item.balance !==null">余额{{item.balance}}.00</view>
						<view style="color: #A6A6A6;font-size: 26upx;" v-else>余额0.00</view>
					</view>
				</view>
				
				<view style="display: flex;flex-direction: column;align-items: center;" v-if="isShowBalace ">
					<image style="width: 350upx;height: 240upx;margin-top: 150upx;" src="../../static/images/order-default-no.png" mode=""></image>
					<view style="color: #B7B8BB;font-size: 28upx;margin-top: 20upx;">暂无余额明细~</view>
				</view>
			</view>
		</view>
		
		
		
		
		
		
		<view v-if="!isSelect">
			<view style="background: #FFFFFF;width: 702upx;height: 260upx;display: flex;flex-direction: column;align-items: center;
			margin-left: 24upx;margin-right: 24upx;margin-top: 24upx;border-radius: 24upx;">
				<view style="color: #191919;font-size: 30upx;margin-top: 50upx;">预计收入(元)</view>
				<view style="color: #191919;font-size: 72upx;font-weight: bold;margin-top: 20upx;" v-if="estimateRecordList.estimateTotalIncome !==null">{{estimateRecordList.estimateTotalIncome}}.00</view>
				<view style="color: #191919;font-size: 72upx;font-weight: bold;margin-top: 20upx;" v-else>0.00</view>
			</view>
			
			<view style="border-radius: 24upx;background: #FFFFFF;margin-top: 24upx;margin-left: 24upx;margin-right: 24upx;height: 100%;">
				<view style="border-bottom: 2upx solid #F4F4F4;width: 654upx;height: 96upx;line-height: 96upx;margin-left: 24upx;">预计收入明细</view>
				<view v-for="(item,index) in estimateRecordList.detailList" :key="index">
					<view style="display: flex;flex-direction: row;justify-content: space-between;margin-top: 18upx;margin-left: 24upx;margin-right: 24upx;">
						<view style="color: #191919;font-size: 28upx;">{{item.title}}</view>
						<view style="color: #191919;font-size: 32upx;">{{item.techAmount}}</view>
					</view>
					<view style="display: flex;flex-direction: row;justify-content: space-between;margin-top: 8upx;margin-left: 24upx;margin-right: 24upx;">
						<view style="color: #A6A6A6;font-size: 26upx;">
							{{item.demandNo}}
						</view>
						<view style="color: #A6A6A6;font-size: 26upx;">{{item.createTime}}</view>
					</view>
					
					
				</view>
				
				<view style="display: flex;flex-direction: column;align-items: center;" v-if="isShowEstimate ">
					<image style="width: 350upx;height: 240upx;margin-top: 150upx;" src="../../static/images/order-default-no.png" mode=""></image>
					<view style="color: #B7B8BB;font-size: 28upx;margin-top: 20upx;">暂无预计收入明细~</view>
				</view>

			</view>
			
			
			
			
			
			
			
			
			
		</view>
		
	</view>
</template>

<script>
	
	import {balance_record,estimate_record} from '../../api/mine/wallet.js'
	export default {
		data() {
			return {
				isSelect:false,
				code:"",
				balanceRecordList:{
					totalIncome:0,
					detailList:[]
				},
				estimateRecordList:{
					estimateTotalIncome:0,
					detailList:[]
				},
				alipayAccount:"",
				realName:"",
				isShowBalace:false,
				isShowEstimate:false
			}
		},
		onShow() {
			this.getBalanceRecord()
		},
		onLoad(options){
			let type=options.type
			console.log(type)
			if(type==1){
				this.isSelect=true
				this.getBalanceRecord()
			}else{
				this.getEstimateRecord()
			}
		},
		methods: {
			switchTab(code){
				this.isSelect = !this.isSelect
				if(code==1){
					
					this.getBalanceRecord()
					
				}else{
					this.getEstimateRecord()
				}
			},
			getBalanceRecord(){
				let params={}
				balance_record(params).then(res=>{
					if(res.status===200){
						this.balanceRecordList.totalIncome=res.data.totalIncome
						this.alipayAccount=res.data.alipayAccount
						this.realName=res.data.realName
						if(res.data.detailList !==null){
							this.balanceRecordList.detailList=res.data.detailList
						}else{
							this.isShowBalace=true
						}
						console.log(this.isShowBalace)
						
					}
					
				})
			},
			getEstimateRecord(){
				let params={}
				estimate_record(params).then(res=>{
					if(res.status===200){
						this.estimateRecordList.estimateTotalIncome=res.data.estimateTotalIncome
						if(res.data.detailList !==null){
							this.estimateRecordList.detailList=res.data.detailList
							
						}else{
							this.isShowEstimate=true
						}
					}
					
				})
			},
			
			applyWithdraw(){
				uni.navigateTo({
					url:'../withdraw/withdraw?amount='+this.balanceRecordList.totalIncome+"&alipayAccount="+this.alipayAccount+"&realName="+this.realName
				})
			},
		}
	}
</script>

<style>

</style>
